\hypertarget{class_neighbour}{
\section{Neighbour Class Reference}
\label{class_neighbour}\index{Neighbour@{Neighbour}}
}


implements spatial hashing for the search of particle neighbours  




{\ttfamily \#include $<$Neighbour.h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_neighbour_a464a3a51675edfbb8cfec88c3de91ebc}{Neighbour} (const int \_\-numParticles, const float \_\-smoothingLength)
\begin{DoxyCompactList}\small\item\em ctor \end{DoxyCompactList}\item 
\hyperlink{class_neighbour_a87c53da1e88911a67a023158f0559184}{$\sim$Neighbour} ()
\begin{DoxyCompactList}\small\item\em dtor \end{DoxyCompactList}\item 
void \hyperlink{class_neighbour_ad22bcb01bb2417b72a7fcd8b90a79a09}{reInitialise} (const int \_\-numParticles, const float \_\-smoothingLength)
\begin{DoxyCompactList}\small\item\em reinitialise the spatial structure \end{DoxyCompactList}\item 
void \hyperlink{class_neighbour_ac7a203985e38320c0f2bb36cfae8d1db}{refreshHashmap} (std::vector$<$ \hyperlink{class_fluid_particle}{FluidParticle} $>$ \&\_\-particleList)
\begin{DoxyCompactList}\small\item\em refresh the hash map at each iteration \end{DoxyCompactList}\item 
void \hyperlink{class_neighbour_ac5219c1009d99b0ebe826087d3aab5ac}{clearHashmap} ()
\begin{DoxyCompactList}\small\item\em clear the hash map \end{DoxyCompactList}\item 
std::vector$<$ \hyperlink{class_fluid_particle}{FluidParticle} $>$ \hyperlink{class_neighbour_a7471239b94e3d9a882766ad5ecb44316}{determineNeighbours} (const ngl::Vector \_\-centerPosition)
\begin{DoxyCompactList}\small\item\em return neighbours of a particle \end{DoxyCompactList}\item 
void \hyperlink{class_neighbour_a75e87e5ea2d87453a9eafd180bf2ddd4}{setCellSize} (const ngl::Real \_\-size)
\begin{DoxyCompactList}\small\item\em set the cell size of the spatial structure \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{class_neighbour_a83185ff29c18e2cd92529885d719dbc3}{modulus} (const int \_\-a, const int \_\-b)
\begin{DoxyCompactList}\small\item\em calculate the modulus of 2 numbers \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_a95f67e745f477afdf627c6c2beed5ae9}{getNextPrimeNumber} (const int \_\-start)
\begin{DoxyCompactList}\small\item\em return the next prime number \end{DoxyCompactList}\item 
std::vector$<$ int $>$ \hyperlink{class_neighbour_aed02495f45b72a43a53882dc62d3b21d}{discretize} (const ngl::Vector \_\-position)
\begin{DoxyCompactList}\small\item\em discretise an array of vectors into an array of integers \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_a4e1686919279b559909c6dec26c44e84}{hashPosition} (const ngl::Vector \_\-position)
\begin{DoxyCompactList}\small\item\em hash a position to a hash key \end{DoxyCompactList}\item 
void \hyperlink{class_neighbour_af1ad511257ca0e2395f0ef48535c15e6}{getCellNeighbours} (const ngl::Vector \_\-centerPosition, const bool \_\-checkWithinSmoothingLength, std::vector$<$ \hyperlink{class_fluid_particle}{FluidParticle} $>$ \&o\_\-neighbourList)
\begin{DoxyCompactList}\small\item\em determine neighbours of a particle, given its position \end{DoxyCompactList}\item 
bool \hyperlink{class_neighbour_a3a935ac13637579ccd2c5f73cb466f5b}{isParticleAlreadyInList} (const int \_\-testId, std::vector$<$ \hyperlink{class_fluid_particle}{FluidParticle} $>$ \&\_\-neighbourList)
\begin{DoxyCompactList}\small\item\em check if a neighbour is a duplicate \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hyperlink{_neighbour_8h_a1b38b0ad37d6e1390643e8d735273c7f}{hashmap} \hyperlink{class_neighbour_af3c75e724bb74d7980ae274835264857}{m\_\-hashMap}
\begin{DoxyCompactList}\small\item\em the spatial hash map \end{DoxyCompactList}\item 
float \hyperlink{class_neighbour_ad03c5fa45f17bc687466bf5b67de318f}{m\_\-cellSize}
\begin{DoxyCompactList}\small\item\em the cell size used for spatial calculations \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_abb730dcbc44131cf5821a7b576eaf4d9}{m\_\-mapSize}
\begin{DoxyCompactList}\small\item\em the map size \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_a3c9b03b5e6c8f8186989dd2d740cea53}{m\_\-largePrime1}
\begin{DoxyCompactList}\small\item\em large prime number 1 \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_a3df982ca6edc60f052f32d9b20c707ed}{m\_\-largePrime2}
\begin{DoxyCompactList}\small\item\em large prime number 2 \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_aafa5627b91bc8c7efcc8a4b13a9be403}{m\_\-largePrime3}
\begin{DoxyCompactList}\small\item\em large prime number 3 \end{DoxyCompactList}\item 
int \hyperlink{class_neighbour_aca74452fddf35a5decadda33996e491c}{m\_\-initialNeighbourListSize}
\begin{DoxyCompactList}\small\item\em reserved space size for neighbours \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
implements spatial hashing for the search of particle neighbours 

Definition at line 21 of file Neighbour.h.



\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_neighbour_a464a3a51675edfbb8cfec88c3de91ebc}{
\index{Neighbour@{Neighbour}!Neighbour@{Neighbour}}
\index{Neighbour@{Neighbour}!Neighbour@{Neighbour}}
\subsubsection[{Neighbour}]{\setlength{\rightskip}{0pt plus 5cm}Neighbour::Neighbour (
\begin{DoxyParamCaption}
\item[{const int}]{\_\-numParticles, }
\item[{const float}]{\_\-smoothingLength}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_a464a3a51675edfbb8cfec88c3de91ebc}


ctor 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-numParticles} & the fluid particle count \\
\hline
\mbox{\tt in}  & {\em \_\-smoothingLength} & the smoothing length \\
\hline
\end{DoxyParams}


Definition at line 10 of file Neighbour.cpp.


\begin{DoxyCode}
{
    //initialise large prime numbers
    m_largePrime1 = 73856093;
    m_largePrime2 = 19349663;
    m_largePrime3 = 83492791;

    //initialise neighbour list
    m_initialNeighbourListSize = 50;

    //initialise hash params
    reInitialise(_numParticles, _smoothingLength);
}
\end{DoxyCode}
\hypertarget{class_neighbour_a87c53da1e88911a67a023158f0559184}{
\index{Neighbour@{Neighbour}!$\sim$Neighbour@{$\sim$Neighbour}}
\index{$\sim$Neighbour@{$\sim$Neighbour}!Neighbour@{Neighbour}}
\subsubsection[{$\sim$Neighbour}]{\setlength{\rightskip}{0pt plus 5cm}Neighbour::$\sim$Neighbour (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_a87c53da1e88911a67a023158f0559184}


dtor 



Definition at line 27 of file Neighbour.cpp.


\begin{DoxyCode}
{
    //clean up
    std::cout << "Neighbour Cleanup" << std::endl;
}
\end{DoxyCode}


\subsection{Member Function Documentation}
\hypertarget{class_neighbour_ac5219c1009d99b0ebe826087d3aab5ac}{
\index{Neighbour@{Neighbour}!clearHashmap@{clearHashmap}}
\index{clearHashmap@{clearHashmap}!Neighbour@{Neighbour}}
\subsubsection[{clearHashmap}]{\setlength{\rightskip}{0pt plus 5cm}void Neighbour::clearHashmap (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_ac5219c1009d99b0ebe826087d3aab5ac}


clear the hash map 



Definition at line 162 of file Neighbour.cpp.



References m\_\-hashMap.


\begin{DoxyCode}
{
    //clears hashmap
    m_hashMap.clear();
}
\end{DoxyCode}
\hypertarget{class_neighbour_a7471239b94e3d9a882766ad5ecb44316}{
\index{Neighbour@{Neighbour}!determineNeighbours@{determineNeighbours}}
\index{determineNeighbours@{determineNeighbours}!Neighbour@{Neighbour}}
\subsubsection[{determineNeighbours}]{\setlength{\rightskip}{0pt plus 5cm}std::vector$<$ {\bf FluidParticle} $>$ Neighbour::determineNeighbours (
\begin{DoxyParamCaption}
\item[{const ngl::Vector}]{\_\-centerPosition}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_a7471239b94e3d9a882766ad5ecb44316}


return neighbours of a particle 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-centerPosition} & the particle's position \\
\hline
\end{DoxyParams}


Definition at line 231 of file Neighbour.cpp.



References discretize(), getCellNeighbours(), and m\_\-cellSize.


\begin{DoxyCode}
{
    //initialise temp neighbour lists
    std::vector<FluidParticle> neighbourList;
    //neighbourList.reserve(m_initialNeighbourListSize);

    std::vector<FluidParticle> neighbourTempList;
    //neighbourTempList.reserve(m_initialNeighbourListSize);

    //first, get neighbours @ centerposition
    getCellNeighbours(_centerPosition, false, neighbourTempList);

    //then, get neighbours from bounding box [centerPos - cellSize, centerPos + c
      ellSize]
    ngl::Vector limit(m_cellSize, m_cellSize, m_cellSize);
    std::vector<int> discreteMinBounds = discretize(_centerPosition - limit);
    std::vector<int> discreteMaxBounds = discretize(_centerPosition + limit);

    //loop from minBound to maxBound and find neighbours in hashmap
    ngl::Real sampleStep = 0.85;
    for (ngl::Real x = discreteMinBounds[0]; x < discreteMaxBounds[0]; x += sampl
      eStep)
    {
        for (ngl::Real y = discreteMinBounds[1]; y < discreteMaxBounds[1]; y += s
      ampleStep)
        {
            for (ngl::Real z = discreteMinBounds[2]; z < discreteMaxBounds[2]; z 
      += sampleStep)
            {
                //fill in neighbour list with neighbours @ test position(x,y,z)
                getCellNeighbours(ngl::Vector(x, y, z), true, neighbourTempList);
      
            }
        }
    }

    //do a final distance check to ensure neighbours are within smoothing length
    for (int i = 0; i < neighbourTempList.size(); ++i)
    {
        //get separation distance between centerposition and neighbour position
        ngl::Real distance = (_centerPosition - neighbourTempList[i].getPosition(
      )).length();

        //add to final list only if distance is within smoothing length (cell siz
      e)
        if (distance < m_cellSize) neighbourList.push_back(neighbourTempList[i]);
      
    }

    //return final list
    return neighbourList;
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_a7471239b94e3d9a882766ad5ecb44316_cgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_aed02495f45b72a43a53882dc62d3b21d}{
\index{Neighbour@{Neighbour}!discretize@{discretize}}
\index{discretize@{discretize}!Neighbour@{Neighbour}}
\subsubsection[{discretize}]{\setlength{\rightskip}{0pt plus 5cm}std::vector$<$ int $>$ Neighbour::discretize (
\begin{DoxyParamCaption}
\item[{const ngl::Vector}]{\_\-position}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_aed02495f45b72a43a53882dc62d3b21d}


discretise an array of vectors into an array of integers 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-position} & the vector position to discretise \\
\hline
\end{DoxyParams}


Definition at line 124 of file Neighbour.cpp.



References m\_\-cellSize.


\begin{DoxyCode}
{
    std::vector<int> pos;
    pos.reserve(3);

    pos.push_back(floor(_position.m_x / m_cellSize));
    pos.push_back(floor(_position.m_y / m_cellSize));
    pos.push_back(floor(_position.m_z / m_cellSize));

    return pos;
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_aed02495f45b72a43a53882dc62d3b21d_icgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_af1ad511257ca0e2395f0ef48535c15e6}{
\index{Neighbour@{Neighbour}!getCellNeighbours@{getCellNeighbours}}
\index{getCellNeighbours@{getCellNeighbours}!Neighbour@{Neighbour}}
\subsubsection[{getCellNeighbours}]{\setlength{\rightskip}{0pt plus 5cm}void Neighbour::getCellNeighbours (
\begin{DoxyParamCaption}
\item[{const ngl::Vector}]{\_\-centerPosition, }
\item[{const bool}]{\_\-checkWithinSmoothingLength, }
\item[{std::vector$<$ {\bf FluidParticle} $>$ \&}]{o\_\-neighbourList}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_af1ad511257ca0e2395f0ef48535c15e6}


determine neighbours of a particle, given its position 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-centerPosition} & the position of the particle \\
\hline
\mbox{\tt in}  & {\em \_\-checkWithinSmoothingLength} & flag to determine whether only neighbours within the smoothing length are added \\
\hline
\mbox{\tt out}  & {\em o\_\-neighbourList} & stores the list neighbours \\
\hline
\end{DoxyParams}


Definition at line 191 of file Neighbour.cpp.



References Particle::getId(), and Particle::getPosition().


\begin{DoxyCode}
{
    //hash position
    int hashKey = hashPosition(_centerPosition);

    //get particles of cell[hashkey] from hash map
    std::pair<hashmap::iterator, hashmap::iterator> neighbourCandidateList = 
      m_hashMap.equal_range(hashKey);

    //loop over neighbour list
    for (hashmap::iterator candidate = neighbourCandidateList.first; candidate !=
       neighbourCandidateList.second; candidate++)
    {
        //get neighbour particle
        FluidParticle neighbourCandidate = (*candidate).second;

        //consider only non-duplicate candidates
        if (!isParticleAlreadyInList(neighbourCandidate.getId(), o_neighbourList)
      )
        {
            //assume neighbour is valid
            bool isValidToAdd = true;

            //filter only neighbours within smoothing length if check is enabled
            if (_checkWithinSmoothingLength)
            {
                //get separation distance between centerposition and neighbour po
      sition
                ngl::Real distance = (_centerPosition - neighbourCandidate.
      getPosition()).length();

                //check if distance is within smoothing length (cell size)
                if (distance > m_cellSize) isValidToAdd = false;
            }

            //add neighbour particle to neighbour list if valid
            if (isValidToAdd) o_neighbourList.push_back(neighbourCandidate);
        }
    }
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=366pt]{class_neighbour_af1ad511257ca0e2395f0ef48535c15e6_cgraph}
\end{center}
\end{figure}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_af1ad511257ca0e2395f0ef48535c15e6_icgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_a95f67e745f477afdf627c6c2beed5ae9}{
\index{Neighbour@{Neighbour}!getNextPrimeNumber@{getNextPrimeNumber}}
\index{getNextPrimeNumber@{getNextPrimeNumber}!Neighbour@{Neighbour}}
\subsubsection[{getNextPrimeNumber}]{\setlength{\rightskip}{0pt plus 5cm}int Neighbour::getNextPrimeNumber (
\begin{DoxyParamCaption}
\item[{const int}]{\_\-start}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a95f67e745f477afdf627c6c2beed5ae9}


return the next prime number 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-start} & the start number from which to find the next prime number \\
\hline
\end{DoxyParams}


Definition at line 59 of file Neighbour.cpp.


\begin{DoxyCode}
{
    int i = _start;

    bool isPrimeNumberFound = true;
    bool isNextPrimeNumberFound = false;

    //Get Square root of number and iterate, start from 2
    int check = (int)sqrt((double)i);
    for (int j = 2; j <= check; j++)
    {
        if (i % j == 0)
        {
            isPrimeNumberFound = false;
            break;
        }
    }
    if (isPrimeNumberFound)
    {
        //i itself is the next prime number
        return i;
    }
    else
    {
        //i is not a prime number -> must search next one

        i++;
        isPrimeNumberFound = true;

        // Increment current number to find next prime number
        while (isNextPrimeNumberFound == false)
        {
            check = (int)sqrt((double)(i));

            for (int j = 2; j <= check; j++)
            {
                if (i % j == 0)
                {
                    isPrimeNumberFound = false;
                    break;
                }
            }

            if (isPrimeNumberFound)
                isNextPrimeNumberFound = true;
            else
            {
                i++;
                isPrimeNumberFound = true;
            }
        }

        if (isNextPrimeNumberFound)
        {
            //i is the next prime number

            return i;
        }
    }

    //eventually, nothing found?
    return _start;
}
\end{DoxyCode}
\hypertarget{class_neighbour_a4e1686919279b559909c6dec26c44e84}{
\index{Neighbour@{Neighbour}!hashPosition@{hashPosition}}
\index{hashPosition@{hashPosition}!Neighbour@{Neighbour}}
\subsubsection[{hashPosition}]{\setlength{\rightskip}{0pt plus 5cm}int Neighbour::hashPosition (
\begin{DoxyParamCaption}
\item[{const ngl::Vector}]{\_\-position}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a4e1686919279b559909c6dec26c44e84}


hash a position to a hash key 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-position} & the position to hash \\
\hline
\end{DoxyParams}


Definition at line 136 of file Neighbour.cpp.



References discretize(), m\_\-largePrime1, m\_\-largePrime2, m\_\-largePrime3, m\_\-mapSize, and modulus().


\begin{DoxyCode}
{
    //discretize position to array of int
    std::vector<int> discretePosition = discretize(_position);

    //calculate hash key
    int key = modulus((discretePosition[0] * m_largePrime1) ^ (discretePosition[1
      ] * m_largePrime2) ^ (discretePosition[2] * m_largePrime3), m_mapSize);

    return key;
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=346pt]{class_neighbour_a4e1686919279b559909c6dec26c44e84_cgraph}
\end{center}
\end{figure}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=376pt]{class_neighbour_a4e1686919279b559909c6dec26c44e84_icgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_a3a935ac13637579ccd2c5f73cb466f5b}{
\index{Neighbour@{Neighbour}!isParticleAlreadyInList@{isParticleAlreadyInList}}
\index{isParticleAlreadyInList@{isParticleAlreadyInList}!Neighbour@{Neighbour}}
\subsubsection[{isParticleAlreadyInList}]{\setlength{\rightskip}{0pt plus 5cm}bool Neighbour::isParticleAlreadyInList (
\begin{DoxyParamCaption}
\item[{const int}]{\_\-testId, }
\item[{std::vector$<$ {\bf FluidParticle} $>$ \&}]{\_\-neighbourList}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a3a935ac13637579ccd2c5f73cb466f5b}


check if a neighbour is a duplicate 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-testId} & the id of the neighbour to check in the list \\
\hline
\mbox{\tt in}  & {\em \_\-neighbourList} & the list of neighbour that will be used for the duplicate check \\
\hline
\end{DoxyParams}


Definition at line 169 of file Neighbour.cpp.


\begin{DoxyCode}
{
    //assume not found
    bool found = false;

    //loop through the temporary neighbour list
    for (int i = 0; i < _neighbourList.size(); i++)
    {
        if (_neighbourList[i].getId() == _testId)
        {
            found = true;
            break;
        }
    }

    return found;
}
\end{DoxyCode}
\hypertarget{class_neighbour_a83185ff29c18e2cd92529885d719dbc3}{
\index{Neighbour@{Neighbour}!modulus@{modulus}}
\index{modulus@{modulus}!Neighbour@{Neighbour}}
\subsubsection[{modulus}]{\setlength{\rightskip}{0pt plus 5cm}int Neighbour::modulus (
\begin{DoxyParamCaption}
\item[{const int}]{\_\-a, }
\item[{const int}]{\_\-b}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a83185ff29c18e2cd92529885d719dbc3}


calculate the modulus of 2 numbers 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-a} & the first number \\
\hline
\mbox{\tt in}  & {\em \_\-b} & the second number \\
\hline
\end{DoxyParams}


Definition at line 46 of file Neighbour.cpp.


\begin{DoxyCode}
{
    //perform huge integer modulus

    //issue of negative modulus : http://mathforum.org/library/drmath/view/52343.
      html
    //solved at stackoverflow : http://stackoverflow.com/questions/1082917/mod-of
      -negative-number-is-melting-my-brain

    //adapted from StackOverflow
    int modulus = _a % _b;
    return modulus < 0 ? modulus + _b : modulus;
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_a83185ff29c18e2cd92529885d719dbc3_icgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_ac7a203985e38320c0f2bb36cfae8d1db}{
\index{Neighbour@{Neighbour}!refreshHashmap@{refreshHashmap}}
\index{refreshHashmap@{refreshHashmap}!Neighbour@{Neighbour}}
\subsubsection[{refreshHashmap}]{\setlength{\rightskip}{0pt plus 5cm}void Neighbour::refreshHashmap (
\begin{DoxyParamCaption}
\item[{std::vector$<$ {\bf FluidParticle} $>$ \&}]{\_\-particleList}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_ac7a203985e38320c0f2bb36cfae8d1db}


refresh the hash map at each iteration 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-particleList} & the fluid particles \\
\hline
\end{DoxyParams}


Definition at line 147 of file Neighbour.cpp.



References hashPosition(), and m\_\-hashMap.


\begin{DoxyCode}
{
#pragma omp for schedule(dynamic, 50)
    //loop through each particle in the fluid
    for (int i = 0; i < _particleList.size(); ++i)
    {
        //hash position
        int hashKey = hashPosition(_particleList[i].getPosition());

#pragma omp critical
        //add (hashkey, particle) pair to hashmap
        m_hashMap.insert(std::pair<int, FluidParticle>(hashKey, _particleList[i])
      );
    }
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_ac7a203985e38320c0f2bb36cfae8d1db_cgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_ad22bcb01bb2417b72a7fcd8b90a79a09}{
\index{Neighbour@{Neighbour}!reInitialise@{reInitialise}}
\index{reInitialise@{reInitialise}!Neighbour@{Neighbour}}
\subsubsection[{reInitialise}]{\setlength{\rightskip}{0pt plus 5cm}void Neighbour::reInitialise (
\begin{DoxyParamCaption}
\item[{const int}]{\_\-numParticles, }
\item[{const float}]{\_\-smoothingLength}
\end{DoxyParamCaption}
)}}
\label{class_neighbour_ad22bcb01bb2417b72a7fcd8b90a79a09}


reinitialise the spatial structure 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-numParticles} & the fluid particle count \\
\hline
\mbox{\tt in}  & {\em \_\-smoothingLength} & the smoothing length \\
\hline
\end{DoxyParams}


Definition at line 34 of file Neighbour.cpp.


\begin{DoxyCode}
{
    //initialise cell size
    m_cellSize = _smoothingLength;

    //initialise hash map size
    m_mapSize = getNextPrimeNumber(2 * _numParticles);
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_ad22bcb01bb2417b72a7fcd8b90a79a09_icgraph}
\end{center}
\end{figure}


\hypertarget{class_neighbour_a75e87e5ea2d87453a9eafd180bf2ddd4}{
\index{Neighbour@{Neighbour}!setCellSize@{setCellSize}}
\index{setCellSize@{setCellSize}!Neighbour@{Neighbour}}
\subsubsection[{setCellSize}]{\setlength{\rightskip}{0pt plus 5cm}void Neighbour::setCellSize (
\begin{DoxyParamCaption}
\item[{const ngl::Real}]{\_\-size}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{class_neighbour_a75e87e5ea2d87453a9eafd180bf2ddd4}


set the cell size of the spatial structure 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-size} & the new cell size \\
\hline
\end{DoxyParams}


Definition at line 58 of file Neighbour.h.



References m\_\-cellSize.


\begin{DoxyCode}
{ m_cellSize = _size; }
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_neighbour_a75e87e5ea2d87453a9eafd180bf2ddd4_icgraph}
\end{center}
\end{figure}




\subsection{Member Data Documentation}
\hypertarget{class_neighbour_ad03c5fa45f17bc687466bf5b67de318f}{
\index{Neighbour@{Neighbour}!m\_\-cellSize@{m\_\-cellSize}}
\index{m\_\-cellSize@{m\_\-cellSize}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-cellSize}]{\setlength{\rightskip}{0pt plus 5cm}float {\bf Neighbour::m\_\-cellSize}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_ad03c5fa45f17bc687466bf5b67de318f}


the cell size used for spatial calculations 



Definition at line 66 of file Neighbour.h.

\hypertarget{class_neighbour_af3c75e724bb74d7980ae274835264857}{
\index{Neighbour@{Neighbour}!m\_\-hashMap@{m\_\-hashMap}}
\index{m\_\-hashMap@{m\_\-hashMap}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-hashMap}]{\setlength{\rightskip}{0pt plus 5cm}{\bf hashmap} {\bf Neighbour::m\_\-hashMap}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_af3c75e724bb74d7980ae274835264857}


the spatial hash map 



Definition at line 63 of file Neighbour.h.

\hypertarget{class_neighbour_aca74452fddf35a5decadda33996e491c}{
\index{Neighbour@{Neighbour}!m\_\-initialNeighbourListSize@{m\_\-initialNeighbourListSize}}
\index{m\_\-initialNeighbourListSize@{m\_\-initialNeighbourListSize}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-initialNeighbourListSize}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf Neighbour::m\_\-initialNeighbourListSize}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_aca74452fddf35a5decadda33996e491c}


reserved space size for neighbours 



Definition at line 81 of file Neighbour.h.

\hypertarget{class_neighbour_a3c9b03b5e6c8f8186989dd2d740cea53}{
\index{Neighbour@{Neighbour}!m\_\-largePrime1@{m\_\-largePrime1}}
\index{m\_\-largePrime1@{m\_\-largePrime1}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-largePrime1}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf Neighbour::m\_\-largePrime1}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a3c9b03b5e6c8f8186989dd2d740cea53}


large prime number 1 



Definition at line 72 of file Neighbour.h.

\hypertarget{class_neighbour_a3df982ca6edc60f052f32d9b20c707ed}{
\index{Neighbour@{Neighbour}!m\_\-largePrime2@{m\_\-largePrime2}}
\index{m\_\-largePrime2@{m\_\-largePrime2}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-largePrime2}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf Neighbour::m\_\-largePrime2}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_a3df982ca6edc60f052f32d9b20c707ed}


large prime number 2 



Definition at line 75 of file Neighbour.h.

\hypertarget{class_neighbour_aafa5627b91bc8c7efcc8a4b13a9be403}{
\index{Neighbour@{Neighbour}!m\_\-largePrime3@{m\_\-largePrime3}}
\index{m\_\-largePrime3@{m\_\-largePrime3}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-largePrime3}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf Neighbour::m\_\-largePrime3}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_aafa5627b91bc8c7efcc8a4b13a9be403}


large prime number 3 



Definition at line 78 of file Neighbour.h.

\hypertarget{class_neighbour_abb730dcbc44131cf5821a7b576eaf4d9}{
\index{Neighbour@{Neighbour}!m\_\-mapSize@{m\_\-mapSize}}
\index{m\_\-mapSize@{m\_\-mapSize}!Neighbour@{Neighbour}}
\subsubsection[{m\_\-mapSize}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf Neighbour::m\_\-mapSize}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_neighbour_abb730dcbc44131cf5821a7b576eaf4d9}


the map size 



Definition at line 69 of file Neighbour.h.



The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
include/\hyperlink{_neighbour_8h}{Neighbour.h}\item 
src/\hyperlink{_neighbour_8cpp}{Neighbour.cpp}\end{DoxyCompactItemize}
